package 实验报告.实验2;

import javax.swing.*;
import java.util.Random;

public class 打字游戏 {
    public 打字游戏(){
        new gui(this);
    }
    public static void main(String [] args){
        new 打字游戏();
    }
    public void fun(gui g){
        Random r=new Random();
        Thread t=new Thread(()->{
            while(true)
               while(!g.iswait){
                    g.flag=true;
                    char a=(char)(r.nextInt(126-48)+48);
                    g.text.setText(String.valueOf(a));
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
        t.start();
    }
}

